/*fq*/
angular.module('indexApp')
    .controller('invite_friendCtrl', function ($scope, $state, $rootScope, $http, $stateParams) {
        var vm = this;
        $scope.state = $state;
        vm.http = $rootScope.http;
        console.log(sessionStorage.witness_id);
        // $rootScope.alert(sessionStorage.witness_id)
        $http({
            method: 'post',
            url: $rootScope.http + 'witness_info',
            data: {
                witness_id: sessionStorage.witness_id
            }
        })
            .then(function successCallback(res) {
                console.log(res.data);
                if (res.data.code == 0) {
                    vm.data = res.data.data;
                }
            }, function errorCallback(res) {// 请求失败执行代码
                $rootScope.alertError()
            });
        // 放大照片
        vm.img_M = [];
        vm.openImg = function (img, imgs) {
            // vm.openImgItem = img;
            // vm.img_M.push(vm.openImgItem);
            wx.previewImage({
                current: img, // 当前显示图片的http链接
                urls: imgs // 需要预览的图片http链接列表
            });
        };
        vm.witness = function () {
            $http({
                method: 'post',
                url: $rootScope.http + 'help_witness',
                data: {
                    witness_id: sessionStorage.witness_id,
                    user_id:$rootScope.id
                }
            })
                .then(function successCallback(res) {
                    console.log(res.data);
                    if (res.data.code == 0) {
                        $rootScope.alert(res.data.msg,function () {
                            $state.go('main.home')
                        })
                    }else{
                        $rootScope.alert(res.data.msg,function () {
                            $state.go('main.home')
                        })
                    }
                }, function errorCallback(res) {// 请求失败执行代码
                    $rootScope.alertError()
                });
        }
    });